<template>
<div class="stocks" style="width: 800px;height: 400px">
  <el-breadcrumb separator="/">
    <el-breadcrumb-item :to="{ path: '/main' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>物资管理</el-breadcrumb-item>
    <el-breadcrumb-item>物资库存</el-breadcrumb-item>
  </el-breadcrumb>


    <el-card class="box-card">
      <div id="main" style="width: 600px;height:350px;"></div>
    </el-card>
    <el-card class="box-card">
      <div id="bingtu" style="width: 590px;height:225px;"></div>
    </el-card>


    <el-card class="box-card" style="margin-left: 670px;margin-top: -668px; width: 600px;height:665px">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item>
          <el-cascader
            placeholder="请选择分类查询"
            v-model="value"
            :options="options"
            :props="{ expandTrigger: 'hover' }"
           ></el-cascader>
        </el-form-item>
        <el-form-item >
          <el-input v-model="formInline.user" placeholder="物资名称"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :data="tableData"
        border
        style="width: 100%">
        <el-table-column
          prop="date"
          label="图片"
          width="80">
        </el-table-column>
        <el-table-column
          prop="name"
          label="名称"
          width="140">
        </el-table-column>
        <el-table-column
          prop="address"
          label="规格">
        </el-table-column>
        <el-table-column
          prop="address"
          label="库存">
        </el-table-column>
        <el-table-column
          prop="address"
          label="单位">
        </el-table-column>
      </el-table>
      <br>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage4"
        :page-sizes="[100, 200, 300, 400]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="400">
      </el-pagination>
    </el-card>


</div>
</template>

<script >
  /*引入echarts*/
  var echarts = require('echarts')

  export default {
    name: 'stocks',
    data(){
      return{

        value: [],
        options: [
          {
            value: 'zhinan',
            label: '指南',
            children: [{
              value: 'shejiyuanze',
              label: '设计原则',
              children: [{
                value: 'yizhi',
                label: '一致'
              }]
            }]
          }
        ],


        categorykeys: ['阿毛'],
        title: '库存条形图',
        xData: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子'],
        seriesData: [5, 20, 36, 10, 10, 20],

        currentPage4: 4,
        formInline: {
          user: ''
        },
        tableData: [{
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        }, {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }, {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄'
        }]
      }
    },
    mounted(){
      this.drowEcharts();
      this.drowRound();
    },
    methods: {
      handleSizeChange (val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange (val) {
        console.log(`当前页: ${val}`);
      },
      onSubmit () {
        alert('submit!');
      },

      /*绘制一个图表*/

      drowEcharts () {
// 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
// 绘制图表
        myChart.setOption({
          title: {
            text: this.title
          },
          tooltip: {},
          xAxis: {
            data: this.xData
          },
          toolbox: {
            feature: {
              dataZoom: {
                yAxisIndex: false
              },
              dataView: {},
              magicType: { type: ["bar"] }
            }
          },
          legend: {
            data: ['库存量']
          },
          yAxis: {},
          series: [{
            name: '库存量',
            type: 'bar',
            data: this.seriesData
          },

          ]
        });
      },
      /*绘制饼图*/
      drowRound () {
        var myChart = echarts.init(document.getElementById("bingtu"));
        var option = {
          title: {
            text: '库存占比图',
            left: 'left'
          },
          tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c} ({d}%)'
          },
          legend: {
            orient: 'vertical',
            left: 'right',
          },
          series: [
            {
              name: '物资名称',
              type: 'pie',
              radius: '50%',
              data: [
                {value: 1048, name: '搜索引擎'},
                {value: 735, name: '直接访问'},
                {value: 580, name: '邮件营销'},
                {value: 484, name: '联盟广告'},
                {value: 300, name: '视频广告'}
              ],
              emphasis: {
                itemStyle: {
                  shadowBlur: 10,
                  shadowOffsetX: 0,
                  shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
              }
            }
          ]
        };
        myChart.setOption(option);

      },

    }

  }
</script>

<style scoped="" lang="less">
.stocks{
  .box-card{
   margin-top: 10px;
    width:650px ;
  }

}
</style>
